home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Personal Computer World 2009 February
/
PCWFEB09.iso
/
Software
/
Resources
/
Burning & Media
/
GB-PVR 1.2.13
/
GBPVR10213.msi
/
Cabs.w1.cab
/
Details2.aspx.cs177
< prev
next >
Wrap
Text File
|
2008-03-12
|
48KB
|
1,069 lines
using System;
using System.Collections;
using System.Data.Common;
using System.IO;
using System.Text.RegularExpressions;
using System.Web.Caching;
using System.Web.UI.HtmlControls;
using System.Xml;
using System.Threading;
using System.Web;
using GBPVR.Public;
using GBPVRSchedule;
using gbweb.classes;
namespace gbweb
{
/// <summary>
/// Summary description for Details.
/// </summary>
public partial class Details2 : System.Web.UI.Page
{
private Settings guideParams;
protected string programUniqueIdentifier;
protected void Page_Load(object sender, EventArgs e)
{
getTheme();
guideParams = Global.Settings;
ERROR_MESSAGE.Visible = false;
if (!IsPostBack)
{
Schedule scheduleHelper = Global.Schedule;
Programme programme = null;
recordButs_UpdateRecordingTime.Visible = false;
// if this show was already scheduled, view=cancel would have been passed in
ScheduledRecording scheduledRecording = null;
string recorded_quality = string.Empty;
//If there is a parm of rid it means that the show is alredy been recorded
if (Request.Params["rid"] != null)
{
recordingOptionsPanel.Visible = false;
spanRecordCancel.InnerText = "Recording Not Found!";
lnkRecordCancel.CommandName = "cancel";
//Since we are looking at a recorded show the user should be able to see the Stream Now button
streamNow.Visible = true;
scheduledRecording =
scheduleHelper.GetScheduledRecordingByOID(Convert.ToInt32(Request.Params["rid"]));
//If the scheduledRecoding is not null it means that the programme is already scheduled
if (scheduledRecording != null)
{
prePadding.Text = scheduledRecording.getPrePadMinutes().ToString();
postPadding.Text = scheduledRecording.getPostPadMinutes().ToString();
watchLink.PostBackUrl =
Download.GetDownloadUrl(false, false, Convert.ToInt32(Request.Params["rid"]));
watchLink.Visible = false;
// reload recording list
switch (scheduledRecording.getQualitySetting())
{
case (int) Schedule.Quality.Low:
recorded_quality = "Low";
newQuality.SelectedValue = "Low";
break;
case (int) Schedule.Quality.Medium:
recorded_quality = "Medium";
newQuality.SelectedValue = "Medium";
break;
case (int) Schedule.Quality.High:
recorded_quality = "High";
newQuality.SelectedValue = "High";
break;
case (int) Schedule.Quality.Custom1:
recorded_quality = "Custom 1";
newQuality.SelectedValue = "Custom1";
break;
case (int) Schedule.Quality.Custom2:
recorded_quality = "Custom 2";
newQuality.SelectedValue = "Custom2";
break;
case (int) Schedule.Quality.LiveTV:
recorded_quality = "LiveTV";
newQuality.SelectedValue = "LiveTV";
break;
default:
recorded_quality = string.Empty;
newQuality.SelectedValue = string.Empty;
break;
}
recordingQuality.Text = recorded_quality;
switch (scheduledRecording.getRecordingStatus())
{
case ScheduledRecording.STATUS_PENDING:
lnkRecordCancel.CssClass = "but_Cancel";
spanRecordCancel.InnerText = "Cancel Recording";
padStart.Text = Convert.ToString(scheduledRecording.getPrePadMinutes());
padEnd.Text = Convert.ToString(scheduledRecording.getPostPadMinutes());
recordButs_UpdateRecordingTime.Visible = true;
break;
case ScheduledRecording.STATUS_IN_PROGRESS:
lnkRecordCancel.CssClass = "but_Cancel";
spanRecordCancel.InnerText = "Cancel Recording";
padStart.Text = Convert.ToString(scheduledRecording.getPrePadMinutes());
padEnd.Text = Convert.ToString(scheduledRecording.getPostPadMinutes());
recordButs_UpdateRecordingTime.Visible = true;
watchLink.Visible = true;
break;
case ScheduledRecording.STATUS_COMPLETED:
lnkRecordCancel.CssClass = "but_DeleteRecording";
spanRecordCancel.InnerText = "Delete Recording";
watchLink.Visible = true;
break;
case ScheduledRecording.STATUS_COMPLETED_WITH_ERROR:
lnkRecordCancel.CssClass = "but_DeleteRecording";
spanRecordCancel.InnerText = "Delete Recording";
break;
case ScheduledRecording.STATUS_CONFLICT:
lnkRecordCancel.CssClass = "but_Cancel";
spanRecordCancel.InnerText = "Cancel Recording";
break;
case ScheduledRecording.STATUS_PLACE_HOLDER:
lnkRecordCancel.CssClass = "but_Cancel";
spanRecordCancel.InnerText = "Cancel Recording";
break;
case ScheduledRecording.STATUS_DELETED:
lnkRecordCancel.CssClass = "but_RecordThisEpisode";
spanRecordCancel.InnerText = "Record This Episode";
break;
default:
lnkRecordCancel.CssClass = "but_RecordThisEpisode";
spanRecordCancel.InnerText = "Unknown Status!";
break;
}
}
//Populate the programme object with the programme info
if (Request.Params["id"] != null)
{
programme = scheduleHelper.GetProgrammeByOID(int.Parse(Request.Params["id"]));
}
//The show being viewed has not yet been set to record
else
{
programme = null;
}
}
else
{
spanRecordCancel.InnerText = "Record This Episode";
lnkRecordCancel.CommandName = "record";
programme = scheduleHelper.GetProgrammeByOID(int.Parse(Request.Params["id"]));
XmlNode pre = Global.Config.SelectSingleNode("/settings/PreShowPadding");
XmlNode post = Global.Config.SelectSingleNode("/settings/PostShowPadding");
prePadding.Text = pre.InnerText;
postPadding.Text = post.InnerText;
}
if (programme != null)
{
//Check to see if the user has VLC installed to do streaming
bool strmAllowed = File.Exists(Path.Combine(guideParams.strmVLCLoc, "vlc.exe"));
if (strmAllowed)
{
//If the programme is in the current time period (it is airing now) or it was recorded previously then the user can Stream Now
if ((programme.getStartTime() <= DateTime.Now &&
programme.getEndTime() > DateTime.Now.AddMinutes(1)) ||
(Request.Params["rid"] != null && programme.getStartTime() <= DateTime.Now))
{
streamLink.Visible = true;
}
else
{
streamLink.Visible = false;
}
}
else
{
streamLink.Visible = false;
}
//If the programme was already recorded show the button to be able to download/watch the recording
//If the programme is still recording you can not see the button.
if (scheduledRecording != null && programme.getStartTime() <= DateTime.Now &&
programme.getEndTime() <= DateTime.Now)
{
watchLink.Visible = true;
}
else
{
watchLink.Visible = false;
}
//Show programme details
showTitle.Text = programme.getTitle();
programUniqueIdentifier = programme.getUniqueProgrammeIdentifier();
showSubTitle.Text = programme.getSubTitle();
//If the subtitle is empty do not show the search this episode link
if (showSubTitle.Text.Length == 0)
{
episodeSearch.Visible = false;
EPISODE_SUBTITLE.Visible = false;
}
showDescription.Text = DetailDisplay2.getDetailDisplay(programme);
if (recorded_quality != string.Empty)
showDescription.Text += "<br> Recording Quality: " + recordingQuality.Text;
divUniqueID.Visible = programUniqueIdentifier.Length > 0;
showStartDate.Text = programme.getStartTime().ToLongDateString();
//If the programme being viewed is already set to record or is recorded then we want to pull the end time
//from the recording rather than how the program was listed on the EPG.
if (scheduledRecording != null)
{
showTimes.Text = scheduledRecording.getStartTime().ToShortTimeString() + " - " +
scheduledRecording.getEndTime().ToShortTimeString();
}
else
{
showTimes.Text = programme.getStartTime().ToShortTimeString() + " - " +
programme.getEndTime().ToShortTimeString();
}
//Setup the channel display info
Channel channel = scheduleHelper.GetChannelByOID(programme.getChannelOID());
string channelName = channel.getName();
if (channelName.StartsWith(channel.getChannelNumber().ToString()))
// cosmetic stuff for my american friends
{
channelName = channelName.Substring(channel.getChannelNumber().ToString().Length);
}
showChannelName.Text = channelName;
showChannelNumber.Text = Convert.ToString(channel.getChannelNumber());
string channelIcon =
GetChannelIcon(channel.getChannelNumber(), new string[] {channel.getName(), channelName});
if (channelIcon != null)
{
CHANNEL_ICON.InnerHtml = "<img src=\"" +
Download.GetDownloadUrl(false, true, Download.InternalFiles.ChannelIcon,
Server.UrlEncode(channelIcon)) +
"\" alt=\"\" width=\"67\" height=\"50\" hspace=\"0\" vspace=\"0\" border=\"1\" runat=\"server\">";
}
//Set the default recording Quality
quality.SelectedValue = guideParams.recordingQuality;
TimeSpan span = programme.getStartTime() - DateTime.Now;
if (span.Minutes >= 0)
{
reminderButton.Text = "Set Reminder";
ArrayList reminders = scheduleHelper.GetReminderList();
foreach (Programme pgm in reminders)
{
if (pgm.getOID() == programme.getOID())
{
reminderButton.Text = "Kill Reminder";
}
}
}
else
{
reminderButton.Visible = false;
}
}
else
{
streamNow.Visible = false;
reminderButton.Visible = false;
showStartDate.Text = "Season Recording";
subTitlePanel.Visible = false;
descriptionPanel.Visible = false;
divUniqueID.Visible = false;
recordingOptionsPanel.Visible = true;
radioDay.Visible = false;
radioTime.Visible = false;
if (scheduledRecording != null)
{
DAYS_LIST.Visible = true;
showTimes.Text = scheduledRecording.getStartTime().ToShortTimeString() + " - " +
scheduledRecording.getEndTime().ToShortTimeString();
showTitle.Text = scheduledRecording.getFileName();
checkedDays_0.Attributes.Add("disabled", "disabled");
checkedDays_1.Attributes.Add("disabled", "disabled");
checkedDays_2.Attributes.Add("disabled", "disabled");
checkedDays_3.Attributes.Add("disabled", "disabled");
checkedDays_4.Attributes.Add("disabled", "disabled");
checkedDays_5.Attributes.Add("disabled", "disabled");
checkedDays_6.Attributes.Add("disabled", "disabled");
int day_mask = scheduleHelper.getSeasonDayMask(scheduledRecording);
if (day_mask != -1)
{
if ((day_mask & ReoccuringRecordingExtras.DAY_SUNDAY) > 0)
{
checkedDays_6.Checked = true;
}
if ((day_mask & ReoccuringRecordingExtras.DAY_SATURDAY) > 0)
{
checkedDays_5.Checked = true;
}
if ((day_mask & ReoccuringRecordingExtras.DAY_FRIDAY) > 0)
{
checkedDays_4.Checked = true;
}
if ((day_mask & ReoccuringRecordingExtras.DAY_THURSDAY) > 0)
{
checkedDays_3.Checked = true;
}
if ((day_mask & ReoccuringRecordingExtras.DAY_WEDNESDAY) > 0)
{
checkedDays_2.Checked = true;
}
if ((day_mask & ReoccuringRecordingExtras.DAY_TUESDAY) > 0)
{
checkedDays_1.Checked = true;
}
if ((day_mask & ReoccuringRecordingExtras.DAY_MONDAY) > 0)
{
checkedDays_0.Checked = true;
}
}
}
else
{
DAYS_LIST.Visible = false;
showTimes.Text = string.Empty;
showTitle.Text = string.Empty;
}
keepRecordingsInfo.Visible = false;
spanRecordCancel.InnerText = "Update Season Recording";
lnkRecordCancel.CommandName = "update";
//Setup the channel display info
Channel channel = scheduleHelper.GetChannelByOID(scheduledRecording.getChannelOID());
string channelName = channel.getName();
if (channelName.StartsWith(channel.getChannelNumber().ToString()))
// cosmetic stuff for my american friends
{
channelName = channelName.Substring(channel.getChannelNumber().ToString().Length);
}
showChannelName.Text = channelName;
showChannelNumber.Text = Convert.ToString(channel.getChannelNumber());
string channelIcon =
GetChannelIcon(channel.getChannelNumber(), new string[] { channel.getName(), channelName });
if (channelIcon != null)
{
CHANNEL_ICON.InnerHtml = "<img src=\"" +
Download.GetDownloadUrl(false, true, Download.InternalFiles.ChannelIcon,
Server.UrlEncode(channelIcon)) +
"\" alt=\"\" width=\"67\" height=\"50\" hspace=\"0\" vspace=\"0\" border=\"1\" runat=\"server\">";
}
switch ((Schedule.Quality)scheduledRecording.getQualitySetting())
{
case Schedule.Quality.High:
quality.SelectedValue = "High";
newQuality.SelectedValue = "High";
break;
case Schedule.Quality.Medium:
quality.SelectedValue = "Medium";
newQuality.SelectedValue = "Medium";
break;
case Schedule.Quality.Low:
quality.SelectedValue = "Low";
newQuality.SelectedValue = "Low";
break;
case Schedule.Quality.Custom1:
quality.SelectedValue = "Custom1";
newQuality.SelectedValue = "Custom1";
break;
case Schedule.Quality.Custom2:
quality.SelectedValue = "Custom2";
newQuality.SelectedValue = "Custome2";
break;
}
radioTime.Items[0].Enabled = false;
if (scheduledRecording.getStartTime().Year != 0001)
{
radioTime.SelectedValue = "thisTime";
}
else
{
radioTime.SelectedValue = "anyTime";
}
prePadding.Text = scheduledRecording.getPrePadMinutes().ToString();
postPadding.Text = scheduledRecording.getPostPadMinutes().ToString();
}
//Guest Users do not get access to initiatie, delete or cancel recordings.
lnkRecordCancel.Visible = Convert.ToBoolean((string)Session["NotGuestUser"]);
if (Request.Params["rid"] != null && recordingOptionsPanel.Visible)
{
recordingOptionsPanel.Visible = Convert.ToBoolean((string)Session["NotGuestUser"]);
}
}
}
protected void lnkRecordCancel_Click(object sender, EventArgs e)
{
Schedule scheduleHelper = Global.Schedule;
Programme programme = null;
if (Request.Params["id"] != null && lnkRecordCancel.CommandName != "cancel")
{
programme = scheduleHelper.GetProgrammeByOID(int.Parse(Request.Params["id"]));
if (Convert.ToDouble(extendMinutes2.Text) != 0)
{
//Add the number of minutes that was entered to the end time of the recording to set the new end time
DateTime newEndDate =
programme.getEndTime().AddMinutes(Convert.ToDouble(extendMinutes2.Text));
//Set the new end time for the recording
programme.setEndTime(newEndDate);
}
}
bool scheduleReturn = true;
//First we need to validate the user entered valid data
Regex numerics = new Regex("[0-9]");
bool validNumbers = true;
validNumbers = numerics.IsMatch(keepRecordings.Text);
if (validNumbers) validNumbers = numerics.IsMatch(prePadding.Text);
if (validNumbers) validNumbers = numerics.IsMatch(postPadding.Text);
if (validNumbers) validNumbers = numerics.IsMatch(extendMinutes2.Text);
if (!validNumbers)
{
errorMessage.Text = "Must enter valid numbers 0-9 in pad fields, extend end time and recordings to keep fields.";
ERROR_MESSAGE.Visible = true;
return;
}
if (lnkRecordCancel.CommandName == "record")
{
Schedule.Quality quality = 0;
int prePad = Convert.ToInt32(prePadding.Text);
int postPad = Convert.ToInt32(postPadding.Text);
switch (Request.Params["quality"].ToLower())
{
case "high":
quality = Schedule.Quality.High;
break;
case "medium":
quality = Schedule.Quality.Medium;
break;
case "low":
quality = Schedule.Quality.Low;
break;
case "custom1":
quality = Schedule.Quality.Custom1;
break;
case "custom2":
quality = Schedule.Quality.Custom2;
break;
}
if (radioTime.SelectedValue == "once")
{
// schedule one-off recording
Schedule myschedule = Global.Schedule;
scheduleReturn = myschedule.ScheduleOnce(programme, quality, prePad, postPad);
if (scheduleReturn)
{
// build up a list of the recording we already know about
IDictionary knownRecordings = scheduleHelper.LoadKnownRecordings();
if (!knownRecordings.Contains(programme.getOID()))
{
scheduleReturn = false;
}
}
}
else
{
//Schedule Season Recordings
//Set the max number of recordings to keep for the show
int keepnumRecordings = ReoccuringRecordingExtras.KEEP_ALL_FILES;
if (keepRecordings.Text.ToString() != null)
{
try
{
keepnumRecordings = Convert.ToInt32(keepRecordings.Text);
}
catch
{
keepnumRecordings = ReoccuringRecordingExtras.KEEP_ALL_FILES;
}
}
else
{
keepnumRecordings = ReoccuringRecordingExtras.KEEP_ALL_FILES;
}
Schedule myschedule = Global.Schedule;
if (radioTime.SelectedValue == "thisTime")
{
// schedule season recording for any day and this time
if (radioDay.SelectedValue == "anyDay")
{
scheduleReturn = myschedule.ScheduleThisTime(programme, quality, Schedule.DayType.SheduleAnyDay, keepnumRecordings, Schedule.RecType.Season, prePad, postPad);
if (scheduleReturn)
{
// build up a list of the recording we already know about
IDictionary knownRecordings = scheduleHelper.LoadKnownRecordings();
if (!knownRecordings.Contains(programme.getOID()))
{
scheduleReturn = false;
}
}
}
// schedule season recording for only this day and this time
else if (radioDay.SelectedValue == "thisDay")
{
scheduleReturn = myschedule.ScheduleThisTime(programme, quality, Schedule.DayType.SheduleThisDay, keepnumRecordings, Schedule.RecType.Season, prePad, postPad);
if (scheduleReturn)
{
// build up a list of the recording we already know about
IDictionary knownRecordings = scheduleHelper.LoadKnownRecordings();
if (!knownRecordings.Contains(programme.getOID()))
{
scheduleReturn = false;
}
}
}
// schedule season recording for the selected days and this time
else
{
//Validate that the person selected at least one day to record
if (!checkedDays_0.Checked && !checkedDays_1.Checked && !checkedDays_2.Checked &&
!checkedDays_3.Checked && !checkedDays_4.Checked && !checkedDays_5.Checked &&
!checkedDays_6.Checked)
{
errorMessage.Text = "Must select at least one day for Specif Day(s) scheduling";
ERROR_MESSAGE.Visible = true;
return;
}
ArrayList dayList = new ArrayList();
// Iterate through the Items collection of the checkedDays
// control and create the correct number for the season recording.
if (checkedDays_0.Checked)
{
dayList.Add(Schedule.Day.Monday);
}
if (checkedDays_1.Checked)
{
dayList.Add(Schedule.Day.Tuesday);
}
if (checkedDays_2.Checked)
{
dayList.Add(Schedule.Day.Wednesday);
}
if (checkedDays_3.Checked)
{
dayList.Add(Schedule.Day.Thursday);
}
if (checkedDays_4.Checked)
{
dayList.Add(Schedule.Day.Friday);
}
if (checkedDays_5.Checked)
{
dayList.Add(Schedule.Day.Saturday);
}
if (checkedDays_6.Checked)
{
dayList.Add(Schedule.Day.Sunday);
}
scheduleReturn = myschedule.ScheduleThisTime(programme, quality, Schedule.DayType.SheduleSpecificDays, keepnumRecordings, dayList, Schedule.RecType.Season, prePad, postPad);
if (scheduleReturn)
{
// build up a list of the recording we already know about
IDictionary knownRecordings = scheduleHelper.LoadKnownRecordings();
if (!knownRecordings.Contains(programme.getOID()))
{
scheduleReturn = false;
}
}
}
}
else
{
// schedule season recording for any day any time
if (radioDay.SelectedValue == "anyDay")
{
scheduleReturn = myschedule.ScheduleAnyTime(programme, quality, Schedule.DayType.SheduleAnyDay, keepnumRecordings, Schedule.RecType.Season, prePad, postPad);
if (scheduleReturn)
{
// build up a list of the recording we already know about
IDictionary knownRecordings = scheduleHelper.LoadKnownRecordings();
if (!knownRecordings.Contains(programme.getOID()))
{
scheduleReturn = false;
}
}
}
// schedule season recording for only this day and this time
else if (radioDay.SelectedValue == "thisDay")
{
scheduleReturn = myschedule.ScheduleAnyTime(programme, quality, Schedule.DayType.SheduleThisDay, keepnumRecordings, Schedule.RecType.Season, prePad, postPad);
if (scheduleReturn)
{
// build up a list of the recording we already know about
IDictionary knownRecordings = scheduleHelper.LoadKnownRecordings();
if (!knownRecordings.Contains(programme.getOID()))
{
scheduleReturn = false;
}
}
}
// schedule season recording for the selected days and this time
else
{
ArrayList dayList = new ArrayList();
//Validate that the person selected at least one day to record
if (!checkedDays_0.Checked && !checkedDays_1.Checked && !checkedDays_2.Checked &&
!checkedDays_3.Checked && !checkedDays_4.Checked && !checkedDays_5.Checked &&
!checkedDays_6.Checked)
{
errorMessage.Text = "Must select at least one day for Specif Day(s) scheduling";
ERROR_MESSAGE.Visible = true;
return;
}
// Iterate through the Items collection of the checkedDays
// control and create the correct number for the season recording.
if (checkedDays_0.Checked)
{
dayList.Add(Schedule.Day.Monday);
}
if (checkedDays_1.Checked)
{
dayList.Add(Schedule.Day.Tuesday);
}
if (checkedDays_2.Checked)
{
dayList.Add(Schedule.Day.Wednesday);
}
if (checkedDays_3.Checked)
{
dayList.Add(Schedule.Day.Thursday);
}
if (checkedDays_4.Checked)
{
dayList.Add(Schedule.Day.Friday);
}
if (checkedDays_5.Checked)
{
dayList.Add(Schedule.Day.Saturday);
}
if (checkedDays_6.Checked)
{
dayList.Add(Schedule.Day.Sunday);
}
scheduleReturn = myschedule.ScheduleAnyTime(programme, quality, Schedule.DayType.SheduleSpecificDays, keepnumRecordings, dayList, Schedule.RecType.Season, prePad, postPad);
if (scheduleReturn)
{
// build up a list of the recording we already know about
IDictionary knownRecordings = scheduleHelper.LoadKnownRecordings();
if (!knownRecordings.Contains(programme.getOID()))
{
scheduleReturn = false;
}
}
}
}
}
if (scheduleReturn)
{
// close popup details window
ClientScript.RegisterStartupScript(typeof(String), "startupScript", "<script language=JavaScript>reloadAndClose();</script>", false);
}
else
{
errorMessage.Text = "Recording Failed!";
ERROR_MESSAGE.Visible = true;
}
}
else if (lnkRecordCancel.CommandName == "cancel")
{
ScheduledRecording scheduledRecording = scheduleHelper.GetScheduledRecordingByOID(Convert.ToInt32(Request.Params["rid"]));
if (scheduledRecording != null)
{
scheduleHelper.CancelScheduledRecording(scheduledRecording);
}
ClientScript.RegisterStartupScript(typeof(String), "startupScript", "<script language=JavaScript>reloadAndClose();</script>", false);
}
else if (lnkRecordCancel.CommandName == "update")
{
//Create a scheduled recording object of the programme being viewed so we have something to modify
ScheduledRecording scheduledRecording = scheduleHelper.GetScheduledRecordingByOID(Convert.ToInt32(Request.Params["rid"]));
//Set the pre and post padding minutes
scheduledRecording.setPrePadMinutes(Convert.ToInt32(prePadding.Text));
scheduledRecording.setPostPadMinutes(Convert.ToInt32(postPadding.Text));
//Set the quality
Schedule.Quality quality = 0;
switch (Request.Params["quality"].ToLower())
{
case "high":
quality = Schedule.Quality.High;
break;
case "medium":
quality = Schedule.Quality.Medium;
break;
case "low":
quality = Schedule.Quality.Low;
break;
case "custom1":
quality = Schedule.Quality.Custom1;
break;
case "custom2":
quality = Schedule.Quality.Custom2;
break;
}
scheduledRecording.setQualitySetting((int)quality);
//Use the API to update the recording on the database
scheduleHelper.UpdateScheduledRecording(scheduledRecording);
//Close the window
ClientScript.RegisterStartupScript(typeof(String), "startupScript", "<script language=JavaScript>windowClose();</script>", false);
}
}
private void getTheme()
{
bool use_new_themes = false;
string themeDir = Server.MapPath(Request.ApplicationPath);
if (File.Exists(Path.Combine(themeDir, "select_theme.xml")))
{
XmlDocument configThemes = new XmlDocument();
configThemes.Load(Path.Combine(themeDir, "select_theme.xml"));
XmlNodeList themeConfig = configThemes.SelectNodes("theme_config");
foreach (XmlNode themeOpt in themeConfig)
{
use_new_themes = Convert.ToBoolean(themeOpt.SelectSingleNode("//use_new_themes").InnerText);
}
}
string theme = Convert.ToString(Session["theme"]);
HttpCookie cookie = new HttpCookie("UseNewThemes", use_new_themes.ToString());
cookie.Expires = DateTime.Now.AddYears(1);
Response.Cookies.Add(cookie);
if (theme != null && theme != "" && !use_new_themes)
{
return;
}
else
{
cookie = Request.Cookies["theme"];
if (cookie != null && cookie.Value.Length > 0)
{
theme = cookie.Value;
}
else
{
theme = "Default";
}
if (use_new_themes)
{
Session["theme"] = "themes2/" + theme;
}
else
{
Session["theme"] = "themes/" + theme;
}
return;
}
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
}
#endregion
protected void LinkButton1_Click(object sender, EventArgs e)
{
Schedule scheduleHelper = Global.Schedule;
ScheduledRecording scheduledRecording_check = scheduleHelper.GetScheduledRecordingByOID(Convert.ToInt32(Request.Params["rid"]));
if (scheduledRecording_check == null)
{
Programme programme = scheduleHelper.GetProgrammeByOID(int.Parse(Request.Params["id"]));
if (Convert.ToDouble(extendMinutes2.Text) != 0)
{
//Add the number of minutes that was entered to the end time of the recording to set the new end time
DateTime newEndDate =
programme.getEndTime().AddMinutes(Convert.ToDouble(extendMinutes2.Text));
//Set the new end time for the recording
programme.setEndTime(newEndDate);
}
bool scheduleReturn = true;
Schedule.Quality quality = 0;
int prePad = Convert.ToInt32(prePadding.Text);
int postPad = Convert.ToInt32(postPadding.Text);
switch (Request.Params["quality"].ToLower())
{
case "high":
quality = Schedule.Quality.High;
break;
case "medium":
quality = Schedule.Quality.Medium;
break;
case "low":
quality = Schedule.Quality.Low;
break;
case "custom1":
quality = Schedule.Quality.Custom1;
break;
case "custom2":
quality = Schedule.Quality.Custom2;
break;
}
Schedule myschedule = Global.Schedule;
scheduleReturn = myschedule.ScheduleOnce(programme, quality, prePad, postPad);
if (scheduleReturn)
{
Thread.Sleep(5000);
IList myScheduledRecordings = scheduleHelper.LoadRecordingSchedule();
foreach (ScheduledRecording scheduledRecording in myScheduledRecordings)
{
if (scheduledRecording.getProgrammeOID() == programme.getOID())
{
Response.Redirect("public/Player2.aspx?rid=" + scheduledRecording.getOID() + "&type=sn");
break;
}
}
errorMessage.Text = "Stream Now Failed!";
ERROR_MESSAGE.Visible = true;
}
else
{
errorMessage.Text = "Stream Now Failed!";
ERROR_MESSAGE.Visible = true;
}
}
else
{
Response.Redirect("public/Player2.aspx?rid=" + scheduledRecording_check.getOID() + "&type=mr");
}
}
protected void reminderButton_Click(object sender, EventArgs e)
{
Schedule scheduleHelper = Global.Schedule;
Programme programme = null;
programme = scheduleHelper.GetProgrammeByOID(int.Parse(Request.Params["id"]));
if (reminderButton.Text == "Set Reminder")
{
scheduleHelper.CreateReminder(programme);
reminderButton.Text = "Kill Reminder";
}
else
{
scheduleHelper.RemoveReminder(programme);
reminderButton.Text = "Set Reminder";
}
}
protected void endTimeUpdate_Click(object sender, EventArgs e)
{
//First we need to validate the user entered valid data
Regex numerics = new Regex("[0-9]");
bool validNumbers = true;
validNumbers = numerics.IsMatch(padStart.Text);
if (validNumbers) validNumbers = numerics.IsMatch(padEnd.Text);
if (validNumbers) validNumbers = numerics.IsMatch(extendMinutes.Text);
if (!validNumbers)
{
errorMessage.Text = "Must enter valid number 0-9 in pad or extend fields";
ERROR_MESSAGE.Visible = true;
return;
}
//Create a new schedulehelper
Schedule scheduleHelper = Global.Schedule;
//Create a scheduled recording object of the programme being viewed so we have something to modify
ScheduledRecording scheduledRecording = scheduleHelper.GetScheduledRecordingByOID(Convert.ToInt32(Request.Params["rid"]));
//Set the pre and post padding minutes
scheduledRecording.setPrePadMinutes(Convert.ToInt32(padStart.Text));
scheduledRecording.setPostPadMinutes(Convert.ToInt32(padEnd.Text));
//Add the number of minutes that was entered to the end time of the recording to set the new end time
DateTime newEndDate = scheduledRecording.getEndTime().AddMinutes(Convert.ToDouble(extendMinutes.Text));
//Set the new end time for the recording
scheduledRecording.setEndTime(newEndDate);
//Set the new Quality
Schedule.Quality Newquality = 0;
switch (newQuality.SelectedValue.ToLower())
{
case "high":
Newquality = Schedule.Quality.High;
break;
case "medium":
Newquality = Schedule.Quality.Medium;
break;
case "low":
Newquality = Schedule.Quality.Low;
break;
case "custom1":
Newquality = Schedule.Quality.Custom1;
break;
case "custom2":
Newquality = Schedule.Quality.Custom2;
break;
}
scheduledRecording.setQualitySetting((int)Newquality);
//USe the API to update the recording on the database
scheduleHelper.UpdateScheduledRecording(scheduledRecording);
//Close the window
ClientScript.RegisterStartupScript(typeof(String), "startupScript", "<script language=JavaScript>windowClose();</script>", false);
}
private static string channelIconPath;
private static string[] channelIconExtensions;
public string GetChannelIcon(int channelNumber, string[] channelNames)
{
// Get the Channel Icon Directory
if (channelIconPath == null)
{
lock (typeof(Details2))
{
if (channelIconPath == null)
{
channelIconPath = Path.Combine(Global.Settings.GetInstallDir(), @"media\ChannelLogos");
channelIconExtensions = Global.Settings.channelIconExtensions.Split(',');
}
}
}
Hashtable channelIconCache = (Hashtable)Cache["channelIconCache"];
if (channelIconCache == null)
{
lock (typeof(Details2))
{
channelIconCache = (Hashtable)Cache["channelIconCache"];
if (channelIconCache == null)
{
channelIconCache = new Hashtable();
Cache.Add(
"channelIconCache",
channelIconCache,
new CacheDependency(channelIconPath),
//DateTime.MaxValue,
DateTime.Now.AddMinutes(30),
//TimeSpan.Zero,
Cache.NoSlidingExpiration,
CacheItemPriority.Normal,
null);
}
}
}
if (channelIconCache.ContainsKey(channelNumber))
{
return (string)channelIconCache[channelNumber];
}
lock (channelIconCache)
{
if (channelIconCache.ContainsKey(channelNumber))
{
return (string)channelIconCache[channelNumber];
}
string channelIconFile = null;
foreach (string channelName in channelNames)
{
foreach (string channelIconExtension in channelIconExtensions)
{
string cleanName = channelName;
string channelNameWork = channelName;
while (cleanName.Contains("/"))
{
if (channelNameWork.Contains("/"))
{
cleanName = channelNameWork.Remove(channelNameWork.IndexOf("/"), 1);
channelNameWork = cleanName;
}
}
string probeFile = cleanName + "." + channelIconExtension;
if (File.Exists(Path.Combine(channelIconPath, probeFile)))
{
channelIconFile = probeFile;
break;
}
}
if (channelIconFile != null) break;
}
channelIconCache[channelNumber] = channelIconFile;
return channelIconFile;
}
}
}
}